import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class Test {
    public static void main(String[] args) {
        Map<Integer,String> map=new TreeMap<>();
        map.put(2,"java2");
        map.put(8,"java8");
        map.put(8,"java4");
        map.put(4,"java4");
        map.put(9,"java9");
        map.put(1,"java1");
       /* Set<Integer> keys=map.keySet();
        for (int key: keys) {
            String val=map.get(key);
            System.out.println(key+"--->"+val);
        }*/
       /* map.forEach((k,v)->{
            System.out.println(k+"---"+v);
        });*/
        Set<Map.Entry<Integer,String> > entrys=map.entrySet();
        for (Map.Entry<Integer,String> entry: entrys ){
            Integer key= entry.getKey();
            String val=entry.getValue();
            System.out.println(key+"---"+val);
        }
    }
}
